<?php
function genarate_page_static_url($type = 'introduction') {
    if($type == 'introduction')
        return '/gioi-thieu.html';
    elseif($type == 'hosting')
        return '/hosting.html';
    elseif($type == 'contact') 
        return '/lien-he.html';
    elseif($type == 'tkw') 
        return '/thiet-ke-web.html';
    elseif($type == 'ga') 
        return '/dich-vu-google-adword.html';
    elseif($type == 'tuw') 
        return '/dich-vu-toi-uu-web.html';
    elseif($type == 'seo') 
        return '/dich-vu-seo-web.html';
    elseif($type == 'h') 
        return '/dich-vu-hosting.html';
    elseif($type == 'd') 
        return '/dich-vu-domain.html';
}

function generate_share_cat_url($cat,$page=1) {
    if($page<=1) {
        return '/chia-se/' .removeTitle($cat['cat_name']). '-' .$cat['cat_id']. '/';
    }else {
        return '/chia-se/' .removeTitle($cat['cat_name']). '-' .$cat['cat_id']. '/trang_'.$page.'/';
    }
}
function generate_share_detail_url($share) {
    return '/chia-se/' .removeTitle($share['sha_title']). '-' .$share['sha_id']. '.html';
}
function generate_service_webdesign_detail_url($service) {
    return '/thiet-ke-web/' .removeTitle($service['ser_title']). '-' .$service['ser_id']. '.html';
}
function generate_partner_detail_url($partner) {
    return '/doi-tac/' .removeTitle($partner['par_title']). '-' .$partner['par_id']. '.html';
}

function generate_page_detail_url($page) {
    return '/' .removeTitle($page['pag_title']). '-' .$page['pag_id']. '.html';
}

function generate_news_detail_url($news) {
    return '/tin-tuc/' .removeTitle($news['new_title']). '-' .$news['new_id']. '.html';
}

function generate_news_cat_url($news_cat) {
    return '/danh-muc-tin/' .removeTitle($news_cat['cat_name']). '-' .$news_cat['cat_id']. '.html';
}
function removeTitle($string,$keyReplace = "/"){
	 $string = removeSign($string);
	 $string  =  trim(preg_replace("/[^A-Za-z0-9]/i"," ",$string)); // khong dau
	 $string  =  str_replace(" ","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace($keyReplace,"-",$string);
	 return strtolower($string);
}
?>